//
//  YBNewsDetailController.m
//  Cocoachina
//
//  Created by 尚往文化 on 17/9/13.
//  Copyright © 2017年 YBing. All rights reserved.
//

#import "YBNewsDetailController.h"
#import <TFHpple.h>
#import <MJRefresh.h>

@interface YBNewsDetailController ()

@end

@implementation YBNewsDetailController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    YBWeakSelf
    self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakSelf reloadData];
    }];
}

- (void)hideHeader
{
//    var root=document.getElementsByClassName("root")[0];
//    root.style.cssText="background-color: blue;color: #fff;";
    
    NSString *addfuncjs = @"function yb_add_hideHeader(){\
    var obj = document.getElementsByTagName(\"header\")[0];\
    var mthead = document.getElementsByClassName(\"mthead\")[0];\
    mthead.style.cssText=\"padding-top: 0px;margin-top: 0px;\";\
    obj.style.display=\"none\";\
    var bottom_ad = document.getElementsByClassName(\"bottom-ad\")[0];\
    bottom_ad.style.display=\"none\";\
    var footer = document.getElementsByTagName(\"footer\")[0];\
    footer.style.display=\"none\";\
    }";
    
    NSString *run_func = @"yb_add_hideHeader()";
    [self runJS:addfuncjs];
    [self runJS:run_func];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [super webViewDidFinishLoad:webView];
    [self hideHeader];
}



@end
